#ifndef __CHANNDL_HPP__
#define __CHANNDL_HPP__

#include <iostream>
#include <string>
#include <unistd.h>

class channel
{
public:
    channel(int wfd, pid_t id)
        : _wfd(wfd), _id(id)
    {
        _name = "Channel-" + std::to_string(wfd) + "-" + std::to_string(id);
    }
    std::string Name()
    {
        return _name;
    }
    //发送任务
    void Send(int cmd)
    {
        ::write(_wfd,&cmd,sizeof(cmd));
    }
    //关闭写端
    void Close()
    {
        ::close(_wfd);
    }
    //子进程id
    pid_t Id()
    {
        return _id;
    }
	//记录的写端
	int Wfd()
	{
		return _wfd;
	}
    ~channel()
    {
    }

private:
    int _wfd;
    std::string _name;
    pid_t _id;
};

#endif